﻿using System;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace ParkingDataSimulate
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);

            var timeZone = TimeZoneInfo.FindSystemTimeZoneById("China Standard Time");
            var TimeZoneList = TimeZoneInfo.GetSystemTimeZones();
            string utc = $"{DateTime.UtcNow:yyyy-MM-dd HH:mm:ss} {TimeZoneList[0].BaseUtcOffset}";
            Console.WriteLine($"Hello World! {DateTime.Now:f}  [{utc}] [{timeZone.BaseUtcOffset}]");

            Console.WriteLine("--------------------------------------------------");

            int IntervalSeconds = 5;
            ParkingDataSimulateTask.Stop = false;
            ParkingDataSimulateTask.IntervalSeconds = IntervalSeconds; ;
           
            ParkingDataSimulateTask.RunSecondlyGlobalProgram(IntervalSeconds).GetAwaiter();

            //==========================================================================================
            int i = 0;
            while (i<300)
            {
                Thread.Sleep(1000);
                Console.WriteLine($"SLEEP . {i}");
                i++;
            }
         
            ParkingDataSimulateTask2.Stop = false;
            ParkingDataSimulateTask2.IntervalSeconds = IntervalSeconds;
            ParkingDataSimulateTask2.RunSecondlyGlobalProgram(IntervalSeconds).GetAwaiter();
             
            while (true)
            {
                Console.WriteLine("PRESS ESC KEY  TO EXIT....");
                ConsoleKey key = Console.ReadKey().Key;
                if (key == ConsoleKey.Escape)
                    break; 
            }
            return;
        }
    }
}
